package com.example.yls.demoa;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
private Button btn1;
private Button btn2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        btn1=findViewById(R.id.btn_1);
        btn2=findViewById(R.id.btn_2);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //显式调用 第一种
                /*Intent intent=new Intent();
                intent.setClass(MainActivity.this,
                     ActivityB.class);
                startActivity(intent);*/
                //显式调用 第二种
              /*  Intent intent2=new Intent();
                intent2.setClassName("com.example.yls.demoa",
                        "com.example.yls.demoa.ActivityB");
                startActivity(intent2);*/
                //显式调用 第三种
                Intent intent3=new Intent();
                intent3.setClassName(MainActivity.this,
                        "com.example.yls.demoa.ActivityB");
                startActivity(intent3);
            }
        });
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent();
               /* intent.setAction(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("http://www.baidu.com"));*/
               intent.setAction("i_want_eat");
               intent.setAction("chilken_rice");
                startActivity(intent);

            }
        });
    }
}
